// noinspection JSUnusedGlobalSymbols
import { getInfo,getRouters } from '@/api/userInfo'
import { defineStore } from 'pinia'
import{Role} from '@/interface/user'
import { RouteItem } from "@/interface/user/userRouters";
export const useUserStore = defineStore('userID', {
  state: ():{
    roles:Role[],
    rolePerm:string,
    userInfo
  } => {
    return {
      roles:[],
      rolePerm:'',
    }
  },
  getters: {},
  actions: {
    async getUserInfo(){
      let res = await getInfo()
      let {permissions,roles,units,userInfo } = res.data
      this.roles = roles
      this.rolePerm = roles[0].rolePerm
    },

  },
  persist: {
    enabled: true, //开启数据缓存
    strategies: [
      {
        storage: localStorage,//默认走session
        paths: ['rolePerm', 'roles']
      }
    ]
  }
})
